import { Controller, Get, Inject, Query } from '@midwayjs/core';
import { NovelService } from '../../service/novel.service';
import { R } from '../common/vo/Result';

@Controller('/novel')
export class NovelController {
    @Inject()
    novelService :NovelService;
   
    @Get('/test')
    async test(){
      let novals = await this.novelService.findNovel()
      return new R(0,"hello my novel",novals);
    }
    @Get('/info')
    async findNovelById(@Query("id") id: number){
      let novals = await this.novelService.findChapterById(id)
      return new R(0,"hello my novel",novals);
    }
    @Get('/chapter/all')
    async findChapterById(@Query("novelId") novelId: number){
      let chapter = await this.novelService.findAllChapterByNovelId(novelId)
      return new R(0,"hello my novel",chapter);
    }

    @Get('/chapter/ctn')
    async findChapterContentByChapterId(@Query("chapterId") chapterId: number){
      let chapterContent = await this.novelService.findChapterContentById(chapterId);
      return new R(0,"hello my novel",chapterContent);
    }
}